package com.google.android.material.appbar;

import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.MeasureSpec;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.coordinatorlayout.widget.CoordinatorLayout.a;
import androidx.core.view.ViewCompat;
import java.util.List;
import o.gr;
import o.hj;
import o.ij;

abstract class HeaderScrollingViewBehavior extends ViewOffsetBehavior<View> {
    private int ˊ;
    final Rect ˋ = new Rect();
    private int ˎ = 0;
    final Rect ˏ = new Rect();

    abstract View ॱ(List<View> list);

    public HeaderScrollingViewBehavior(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public boolean ˎ(CoordinatorLayout coordinatorLayout, View view, int i, int i2, int i3, int i4) {
        int i5 = view.getLayoutParams().height;
        if (i5 == -1 || i5 == -2) {
            View ॱ = ॱ(coordinatorLayout.ˏ(view));
            if (ॱ != null) {
                if (ViewCompat.ॱˋ(ॱ) && !ViewCompat.ॱˋ(view)) {
                    ViewCompat.ˎ(view, true);
                    if (ViewCompat.ॱˋ(view)) {
                        view.requestLayout();
                        return true;
                    }
                }
                int size = MeasureSpec.getSize(i3);
                if (size == 0) {
                    size = coordinatorLayout.getHeight();
                }
                coordinatorLayout.ˋ(view, i, i2, MeasureSpec.makeMeasureSpec(ॱ(ॱ) + (size - ॱ.getMeasuredHeight()), i5 == -1 ? 1073741824 : Integer.MIN_VALUE), i4);
                return true;
            }
        }
        return false;
    }

    protected void ˏ(CoordinatorLayout coordinatorLayout, View view, int i) {
        View ॱ = ॱ(coordinatorLayout.ˏ(view));
        if (ॱ != null) {
            a aVar = (a) view.getLayoutParams();
            Rect rect = this.ˏ;
            rect.set(coordinatorLayout.getPaddingLeft() + aVar.leftMargin, ॱ.getBottom() + aVar.topMargin, (coordinatorLayout.getWidth() - coordinatorLayout.getPaddingRight()) - aVar.rightMargin, ((coordinatorLayout.getHeight() + ॱ.getBottom()) - coordinatorLayout.getPaddingBottom()) - aVar.bottomMargin);
            ij q_ = coordinatorLayout.q_();
            if (!(q_ == null || !ViewCompat.ॱˋ(coordinatorLayout) || ViewCompat.ॱˋ(view))) {
                rect.left += q_.ˏ();
                rect.right -= q_.ˋ();
            }
            Rect rect2 = this.ˋ;
            hj.ˋ(ॱ(aVar.ॱ), view.getMeasuredWidth(), view.getMeasuredHeight(), rect, rect2, i);
            int ˏ = ˏ(ॱ);
            view.layout(rect2.left, rect2.top - ˏ, rect2.right, rect2.bottom - ˏ);
            this.ˎ = rect2.top - ॱ.getBottom();
            return;
        }
        super.ˏ(coordinatorLayout, view, i);
        this.ˎ = 0;
    }

    float ˊ(View view) {
        return 1.0f;
    }

    final int ˏ(View view) {
        if (this.ˊ == 0) {
            return 0;
        }
        return gr.ॱ((int) (ˊ(view) * ((float) this.ˊ)), 0, this.ˊ);
    }

    private static int ॱ(int i) {
        return i == 0 ? 8388659 : i;
    }

    int ॱ(View view) {
        return view.getMeasuredHeight();
    }

    final int ˋ() {
        return this.ˎ;
    }

    public final void ˏ(int i) {
        this.ˊ = i;
    }

    public final int ˏ() {
        return this.ˊ;
    }
}
